home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / COMPILER / SATHER / !Sather / Library / Base / test / sa / aref next >
Text File  |  1996-04-09  |  3KB  |  82 lines

  1. ---------------------------> Sather 1.1 source file <--------------------------
  2. -- test_aref.sa: 
  3. -- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
  4. -- Copyright (C) 1995, International Computer Science Institute
  5. -- $Id: aref_test.sa,v 1.2 1996/04/09 10:04:11 borisv Exp $
  6. --
  7. -- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
  8. -- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
  9. -- LICENSE contained in the file: Sather/Doc/License of the
  10. -- Sather distribution. The license is also available from ICSI,
  11. -- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
  12. -------------------------------------------------------------------
  13. class TEST_AREF is
  14.    include TEST;
  15.    
  16.    main is
  17.       class_name("AREF{INT}");
  18.       a ::= #AREF{INT}(5);
  19.       a[0] := 0; a[1] := 1; a[2] := 2; a[3]:=3; a[4]:=4;
  20.       test("aset and aget",a[2].str,"2");
  21.       res::=""; loop res := res+" "+a.aelt!; end;
  22.       test("aelt!",res," 0 1 2 3 4");
  23.       res:=""; loop res := res+" "+a.aelt!(1); end;
  24.       test("aelt!(beg)",res," 1 2 3 4");
  25.       res:=""; loop res := res+" "+a.aelt!(1,2); end;
  26.       test("aelt!(1,2)",res," 1 2");
  27.       res:=""; loop res := res+" "+a.aelt!(1,2,2); end;
  28.       test("aelt!(1,2,2)",res," 1 3");
  29.  
  30.  
  31.       b ::=#AREF{INT}(a.asize);  
  32.       
  33.       b.acopy(a);
  34.       res:=""; loop res := res+" "+b.aelt!; end;
  35.       test("acopy",res," 0 1 2 3 4");
  36.       
  37.       c ::= #AREF{INT}(3);
  38.       c.acopy(a);
  39.       res:=""; loop res := res+" "+c.aelt!; end;
  40.       test("acopy",res," 0 1 2");
  41.       
  42.       loop b.aset!(1); end;
  43.       res:=""; loop res := res+" "+b.aelt!; end;
  44.       test("aset",res," 1 1 1 1 1");
  45.       
  46.       b.acopy(a);
  47.       loop b.aset!(3,1); end;
  48.       res:=""; loop res := res+" "+b.aelt!; end;
  49.       test("aset(3,1)",res," 0 1 2 1 1");
  50.       
  51.       b.acopy(a);
  52.       loop b.aset!(2,2,7); end;
  53.       res:=""; loop res := res+" "+b.aelt!; end;
  54.       test("aset(2,2,7)",res," 0 1 7 7 4");
  55.  
  56.       b.acopy(a);
  57.       loop b.aset!(1,2,2,9); end;
  58.       res:=""; loop res := res+" "+b.aelt!; end;
  59.       test("aset(1,2,2,9)",res," 0 9 2 9 4");
  60.       
  61.       b.acopy(1,a);
  62.       res:=""; loop res := res+" "+b.aelt!; end;
  63.       test("acopy(1)",res," 0 0 1 2 3");
  64.       
  65.       b.aclear;
  66.       res:=""; loop res := res+" "+b.aelt!; end;
  67.       test("acopy(1)",res," 0 0 0 0 0");
  68.       
  69.       b.acopy(2,2,a);
  70.       res:=""; loop res := res+" "+b.aelt!; end;
  71.       test("acopy(2,2)",res," 0 0 0 1 0");
  72.  
  73.       b.acopy(2,2,2,a);
  74.       res:=""; loop res := res+" "+b.aelt!; end;
  75.       test("acopy(2,2)",res," 0 0 2 3 0");
  76.       finish;
  77.       end;
  78.    
  79. end; -- class TEST_AREF
  80.  
  81. -------------------------------------------------------------------
  82.